#!/bin/bash
#                                                        2016-09-25 Agner Fog
# Compile and run PMCTest for integer vector AVX2 and AVX512 instructions
# looping through list of instructions
# (c) Copyright 2013-2016 by Agner Fog. GNU General Public License www.gnu.org/licenses

# Exit if AVX2 not supported
if  [ `grep -c -i "AVX2" cpuinfo.txt ` -eq 0 ] ; then exit ; fi

# Detect CPU specific variables
. vars.sh

repeat0=10

# List of register sizes
if  [ `grep -c -i "avx512" cpuinfo.txt ` -eq 0 ] ; then
  regsizelist="128 256"
  regsizelistbw="128 256"
  regsizelisty="256"
  echo -e "AVX2 instructions\n\n"  > results1/avx2.txt
else
  regsizelist="128 256 512"
  regsizelisty="256 512"
  if  [ `grep -c -i "avx512bw" cpuinfo.txt ` -ne 0 ] ; then
    regsizelistbw="128 256 512"
  else
    regsizelistbw="128 256"
  fi
  echo -e "AVX2 and AVX512 instructions\n\n"  > results1/avx2.txt
fi

# Instructions requiring AVX512BW for register size 512:
BWinstructions=" vpabsb vpabsw vpacksswb vpackssdw vpackusdw vpackuswb \
vpaddb vpaddw vpaddsb vpaddsw vpaddusb vpaddusw vpsubb vpsubw vpsubsb vpsubsw vpsubusb vpsubusw \
vpavgb vpavgw vpcmpeqb vpcmpeqw vpcmpgtb vpcmpgtw \
vphaddw vphaddsw vphsubw vphsubsw vpmaddubsw vpmaddwd vpmaxsb vpmaxsw vpmaxub vpminsb vpminub \
vpmulhrsw vpmulhuw vpmulhw vpmullw vpsadbw vpshufb vpsignb vpsignw \
vpunpcklbw vpunpckhbw vpunpcklwd vpunpckhwd vpsllvd vpsllvq vpsravd vpsrlvd vpsrlvq vpsllw vpsraw vpsrlw vpslldq vpsrldq \
vpalignr vpblendvb vpshufhw vpshuflw "

# Instructions not supported with 512 bit destination register
XYinstructions=" vpcmpeqb vpcmpeqw vpcmpeqd vpcmpeqq vpcmpgtb vpcmpgtw vpcmpgtd vpcmpgtq \
vphaddw vphaddd vphaddsw vphsubw vphsubd vphsubsw vpsignb vpsignw vpsignd \
vpand vpor vpandn vpxor vmpsadbw vpblendw vpblendd "

# Instructions only supported with 512 bit destination register
Zinstructions=" vpandd vpandq vpord vporq vpandnd vpandnq vpxord vpxorq "


echo -e "integer vector instructions with two operands\n"  >> results1/avx2.txt

for instruct in  vpabsb vpabsw vpabsd
do

# Check if AVX512BW required
  # if echo "$BWinstructions" | grep -q "$instruct" ; then
if [[ "$BWinstructions" == *" $instruct "* ]] ; then
  # This instruction is not supported with 512 bit registers
  rlist=$regsizelistbw
else
  rlist=$regsizelist
fi

for regsize in $rlist
do
r=$regsize

echo -e "\n\nLatency: $instruct r$r,r$r"  >> results1/avx2.txt
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=2 -Dregsize=$regsize -Dcounters=$PMCs -Dtmode=L -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt

echo -e "\n\nThroughput: $instruct r$r,r$r"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=2 -Dregsize=$regsize -Dcounters=$cts -Dtmode=T -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done

echo -e "\n\nThroughput with memory source operand: $instruct r$r,[m$r]"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=2 -Dregsize=$regsize -Dcounters=$cts -Dtmode=M -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done
done
done

echo -e "integer vector instructions with three operands\n"  >> results1/avx2.txt

for instruct in  vpacksswb vpackssdw vpackusdw vpackuswb \
vpaddb vpaddw vpaddd vpaddq vpaddsb vpaddsw vpaddusb vpaddusw \
vpsubb vpsubw vpsubd vpsubq vpsubsb vpsubsw vpsubusb vpsubusw \
vphaddw vphaddd vphaddsw vphsubw vphsubd vphsubsw vpmaddubsw vpmaddwd vpmaxsb vpmaxsw vpmaxsd vpmaxub vpminsb vpminub \
vpmuldq vpmulhrsw vpmulhuw vpmulhw vpmullw vpmulld vpmuludq vpsadbw vpshufb vpsignb vpsignw vpsignd \
vpunpckhbw vpunpckhwd vpunpckhdq vpunpckhqdq vpunpcklbw vpunpcklwd vpunpckldq vpunpcklqdq \
vpsllvd vpsllvq vpsravd vpsrlvd vpsrlvq \
vpand vpandd vpandq vpor vpord vporq vpandn vpandnd vpandnq vpxor vpxord vpxorq \
vpcmpeqb vpcmpeqw vpcmpeqd vpcmpeqq vpcmpgtb vpcmpgtw vpcmpgtd vpcmpgtq

do

# Check if 512 bit destination supported
if  [ `grep -c -i "avx512" cpuinfo.txt ` -eq 0 ] ; then
  rlist=$regsizelist
elif [[ "$XYinstructions" == *" $instruct "* ]] ; then
  rlist="128 256"
elif [[ "$Zinstructions" == *" $instruct "* ]] ; then
  rlist=" 512 "
elif [[ "$BWinstructions" == *" $instruct "* ]] ; then
  rlist=$regsizelistbw
else
  rlist=$regsizelist
fi

for regsize in $rlist
do
r=$regsize

echo -e "\n\nLatency: $instruct r$r,r$r,r$r"  >> results1/avx2.txt
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=3 -Dregsize=$regsize -Dcounters=$PMCs -Dtmode=L -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt

echo -e "\n\nThroughput: $instruct r$r,r$r,r$r"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=3 -Dregsize=$regsize -Dcounters=$cts -Dtmode=T -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done

echo -e "\n\nThroughput with memory source operand: $instruct r$r,r$r,[m$r]"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=3 -Dregsize=$regsize -Dcounters=$cts -Dtmode=M -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done
done
done


echo -e "\n\nInstructions with two registers and one immediate operand\n"  >> results1/avx2.txt

for instruct in  vpshufd vpshufhw vpshuflw
do

# Check if AVX512BW required
if [[ "$BWinstructions" == *" $instruct "* ]] ; then
  rlist=$regsizelistbw
else
  rlist=$regsizelist
fi

for regsize in $rlist
do
r=$regsize

echo -e "\n\nLatency: $instruct r$r,r$r,i"  >> results1/avx2.txt
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=2 -Dregsize=$regsize -Dtmode=L -Dnumimm=1 -Dimmvalue=0 -Dcounters=$PMCs -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt

echo -e "\n\nThroughput: $instruct r$r,r$r,i"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=2 -Dregsize=$regsize -Dtmode=T -Dnumimm=1 -Dimmvalue=5 -Dcounters=$cts -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done

echo -e "\n\nThroughput with memory source operand: $instruct r$r,[m$r],i"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=2 -Dregsize=$regsize -Dtmode=M -Dnumimm=1 -Dimmvalue=2 -Dcounters=$cts -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done
done
done

echo -e "\n\nInstructions with two registers and one immediate operand (memory operand not allowed)\n"  >> results1/avx2.txt

for instruct in  vpsllw vpslld vpsllq vpslldq vpsraw vpsrad vpsrldq vpsrlw vpsrld vpsrlq
do

# Check if AVX512BW required
if [[ "$BWinstructions" == *" $instruct "* ]] ; then
  rlist=$regsizelistbw
else
  rlist=$regsizelist
fi

for regsize in $rlist
do
r=$regsize

echo -e "\n\nLatency: $instruct r$r,r$r,i"  >> results1/avx2.txt
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=2 -Dregsize=$regsize -Dtmode=L -Dnumimm=1 -Dimmvalue=0 -Dcounters=$PMCs -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt

echo -e "\n\nThroughput: $instruct r$r,r$r,i"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=2 -Dregsize=$regsize -Dtmode=T -Dnumimm=1 -Dimmvalue=5 -Dcounters=$cts -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done

done
done


echo -e "\n\nInstructions with three registers and one immediate operand\n"  >> results1/avx2.txt

for instruct in vmpsadbw vpalignr vpblendw vpblendd
do

# Check if 512 bit destination supported
if  [ `grep -c -i "avx512" cpuinfo.txt ` -eq 0 ] ; then
  rlist=$regsizelist
elif [[ "$XYinstructions" == *" $instruct "* ]] ; then
  rlist="128 256"
elif [[ "$Zinstructions" == *" $instruct "* ]] ; then
  rlist=" 512 "
elif [[ "$BWinstructions" == *" $instruct "* ]] ; then
  rlist=$regsizelistbw
else
  rlist=$regsizelist
fi

for regsize in $rlist
do
r=$regsize

echo -e "\n\nLatency: $instruct r$r,r$r,r$r,i"  >> results1/avx2.txt
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=3 -Dregsize=$regsize -Dtmode=L -Dnumimm=1 -Dimmvalue=0 -Dcounters=$PMCs -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt

echo -e "\n\nThroughput: $instruct r$r,r$r,r$r,i"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=3 -Dregsize=$regsize -Dtmode=T -Dnumimm=1 -Dimmvalue=5 -Dcounters=$cts -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done

echo -e "\n\nThroughput with memory source operand: $instruct r$r,r$r,[m$r],i"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=3 -Dregsize=$regsize -Dtmode=M -Dnumimm=1 -Dimmvalue=2 -Dcounters=$cts -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done
done
done

echo -e "integer vector instructions with four operands\n"  >> results1/avx2.txt

for instruct in  vpblendvb

do

for regsize in 128 256  # not 512 bit
do
r=$regsize

echo -e "\n\nLatency: $instruct r$r,r$r,r$r,r$r"  >> results1/avx2.txt
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=4 -Dregsize=$regsize -Dcounters=$PMCs -Dtmode=L -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt

echo -e "\n\nThroughput: $instruct r$r,r$r,r$r,r$r"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=4 -Dregsize=$regsize -Dcounters=$cts -Dtmode=T -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done

echo -e "\n\nThroughput with memory source operand: $instruct r$r,r$r,[m$r],r$r"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=4 -Dregsize=$regsize -Dcounters=$cts -Dtmode=M3 -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done
done
done


echo -e "vector instructions with three operands, $regsizelisty bit only\n"  >> results1/avx2.txt

for instruct in  vpermd vpermps 
do

for regsize in $regsizelisty 
do
r=$regsize

echo -e "\n\nLatency: $instruct r$r,r$r,r$r"  >> results1/avx2.txt
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=3 -Dregsize=$regsize -Dcounters=$PMCs -Dtmode=L -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt

echo -e "\n\nThroughput: $instruct r$r,r$r,r$r"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=3 -Dregsize=$regsize -Dcounters=$cts -Dtmode=T -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done

echo -e "\n\nThroughput with memory source operand: $instruct r$r,r$r,[m$r]"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=3 -Dregsize=$regsize -Dcounters=$cts -Dtmode=M -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done
done
done

echo -e "\n\nInstructions with two registers and one immediate operand, $regsizelisty bit only\n"  >> results1/avx2.txt

for instruct in  vpermq vpermpd
do
for regsize in $regsizelisty
do
r=$regsize

echo -e "\n\nLatency: $instruct r$r,r$r,i"  >> results1/avx2.txt
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=2 -Dregsize=$regsize -Dtmode=L -Dnumimm=1 -Dimmvalue=0 -Dcounters=$PMCs -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt

echo -e "\n\nThroughput: $instruct r$r,r$r,i"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=2 -Dregsize=$regsize -Dtmode=T -Dnumimm=1 -Dimmvalue=5 -Dcounters=$cts -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done

echo -e "\n\nThroughput with memory source operand: $instruct r$r,[m$r],i"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=2 -Dregsize=$regsize -Dtmode=M -Dnumimm=1 -Dimmvalue=2 -Dcounters=$cts -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done
done
done

echo -e "\n\nInstructions with three registers and one immediate operand, 256 bit only\n"  >> results1/avx2.txt

for instruct in vperm2i128 vperm2f128 
do
for regsize in 256
do
r=$regsize

echo -e "\n\nLatency: $instruct r$r,r$r,r$r,i"  >> results1/avx2.txt
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=3 -Dregsize=$regsize -Dtmode=L -Dnumimm=1 -Dimmvalue=0 -Dcounters=$PMCs -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt

echo -e "\n\nThroughput: $instruct r$r,r$r,r$r,i"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=3 -Dregsize=$regsize -Dtmode=T -Dnumimm=1 -Dimmvalue=3 -Dcounters=$cts -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done

echo -e "\n\nThroughput with memory source operand: $instruct r$r,r$r,[m$r],i"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=$instruct -Dnumop=3 -Dregsize=$regsize -Dtmode=M -Dnumimm=1 -Dimmvalue=2 -Dcounters=$cts -Drepeat0=$repeat0 -Plt.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done
done
done

echo -e "\n\nShift instructions with xmm shift count\n"  >> results1/avx2.txt

for instruct in vpsllw vpslld vpsllq vpsraw vpsrad vpsrlw vpsrld vpsrlq
do

# Check if AVX512BW required
if [[ "$BWinstructions" == *" $instruct "* ]] ; then
  rlist=$regsizelistbw
else
  rlist=$regsizelist
fi

for regsize in $rlist
do
r=$regsize

echo -e "\n\nLatency: $instruct r$r,r$r,r128"  >> results1/avx2.txt
$ass -f elf64 -o b64.o -Dinstruct=vshift -Dinstruct1=$instruct -Dnumop=3 -Dregsize=$regsize -Dtmode=L -Dcounters=$PMCs -Drepeat0=$repeat0 -Pmisc_vect.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt

echo -e "\n\nThroughput: $instruct r$r,r$r,r128"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=vshift -Dinstruct1=$instruct -Dnumop=3 -Dregsize=$regsize -Dtmode=T -Dcounters=$cts -Drepeat0=$repeat0 -Pmisc_vect.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done

echo -e "\n\nThroughput with memory source operand: $instruct r$r,r$r,[m128]"  >> results1/avx2.txt
for cts in $PMClist
do
$ass -f elf64 -o b64.o -Dinstruct=vshift -Dinstruct1=$instruct -Dnumop=3 -Dregsize=$regsize -Dtmode=M -Dcounters=$cts -Drepeat0=$repeat0 -Pmisc_vect.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results1/avx2.txt
done
done
done

echo -e "\n"  >> results1/avx2.txt
